package it.polimi.traveldream.web.beans.shared;

import it.polimi.traveldream.ejbclient.dtos.ExcursionDTO;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;


@FacesConverter(forClass=ExcursionDTO.class,value="excursionConverter")
public class SelectExcursionsConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext context, UIComponent component, String value) {
		ExcursionDTO excursion = new ExcursionDTO();
		excursion.setId(Integer.parseInt(value));
		return excursion;
	}

	@Override
	public String getAsString(FacesContext context, UIComponent component, Object value) {
		return String.valueOf(((ExcursionDTO) value).getId());
	}

}
